<template>
  <div ref="chart" class="chart"></div>
</template>

<script>
import * as echarts from 'echarts';

export default {
  name: 'ChartComponent',
  mounted() {
    this.initChart();
  },
  methods: {
    initChart() {
      const chartDom = this.$refs.chart;
      const myChart = echarts.init(chartDom);
      const option = {
        title: {
          text: 'ECharts Example'
        },
        tooltip: {},
        xAxis: {
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        },
        yAxis: {},
        series: [{
          name: 'Sample Data',
          type: 'line',
          data: [120, 200, 150, 80, 70, 110, 130]
        }]
      };
      myChart.setOption(option);
    }
  }
}
</script>

<style>
.chart {
  width: 100%;
  height: 100%;
}
</style>
